package net.anzhuo.service.impl;

import lombok.extern.slf4j.Slf4j;
import net.anzhuo.common.entity.PaginationVO;
import net.anzhuo.dao.GsCashFlowMapper;
import net.anzhuo.entity.GsCashFlow;
import net.anzhuo.service.GsCashFlowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Slf4j
public class GsCashFlowServiceImpl implements GsCashFlowService {

	@Autowired
	private GsCashFlowMapper gsCashFlowMapper;

	@Override
	public PaginationVO<GsCashFlow> getListWithPage(GsCashFlow gsCashFlow) {
		PaginationVO<GsCashFlow> paginationVO = new PaginationVO<>();
		paginationVO.setList(gsCashFlowMapper.getListWithPage(gsCashFlow));
		paginationVO.setTotalCount(gsCashFlowMapper.getCount(gsCashFlow));
		paginationVO.setTotalPage((gsCashFlowMapper.getCount(gsCashFlow) + gsCashFlow.getPageSize() -1)  / gsCashFlow.getPageSize());
		paginationVO.setPageNo(gsCashFlow.getPageNo());
		return paginationVO;
	}

	@Override
	public GsCashFlow getById(Long id) {
		return gsCashFlowMapper.getById(id);
	}

	@Override
	public List<GsCashFlow> getByMd5(String md5) {return gsCashFlowMapper.getByMd5(md5);}


	@Override
	public List<GsCashFlow> getList() {
		return gsCashFlowMapper.getList();
	}

	@Override
	public List<GsCashFlow> getList(GsCashFlow gsCashFlow) {
		return gsCashFlowMapper.getListByQuery(gsCashFlow);
	}

	@Override
	@Transactional(rollbackFor=Throwable.class)
	public void update(GsCashFlow gsCashFlow) {
		gsCashFlowMapper.update(gsCashFlow);
	}

	@Override
	@Transactional(rollbackFor=Throwable.class)
	public void save(GsCashFlow gsCashFlow) {
		gsCashFlowMapper.save(gsCashFlow);
	}

	@Override
	@Transactional(rollbackFor=Throwable.class)
	public void delete(GsCashFlow gsCashFlow) {
		gsCashFlowMapper.delete(gsCashFlow);
	}
}
